Long time waited feature for RealBasic listboxes, the Horizontal scrollbar is here.
But to be a real listbox it needs two more things to me:
Resizeable and Movable columns.
Well, here they are!
Here's the classes details:
Set up:
You need to drag in the same window a ResizeMoveBox and an ActiveHeading
the box will locate the ActiveHeading and init it
ActiveHeading class has
Properties:
• MaxColSize as Integer with this you can set the maximum width a column can have
• MinColSize as Integer with this you can set the minimum width a column can have
• MoveEnabled as Boolean set this to false and the columns will not move
• ResizeEnabled as Boolean set this to false and the columns will not resize
WARNING! if you have set a BrowseColumn subclass (which is the only way to make things work since original class is protected) then you MUST change the creator in your ResizeMoveBox control Open handler to match your subclass name and init all the linked objects as shown in the example project.
In the open event of the ResizeMoveBox you can also create the empty rows that must be filled with
the FillColumns method
e.g. (snippet of example Open event handler) :
for i = 0 to me.ColumnCount - 1
// Best way is to pass a subclass of BrowseColumn object
me.bc(i) = new myCustomBrowseColumn(me, i) <--- here you put the name of your custom
BrowseColumn subclass
// Strongly reccomended that you fill your headings here;
// Should work also with values filled in InitialValue
// at design time but things get too messy… don't know why
me.bc(i).Heading = "Column " + Str(i)
// Could set all the columns properties here
me.bc(i).Alignment = 3
me.bc(i).AlignmentOffset = -5
next
// not strictly necessary, depends on how you handle filling of columns
me.DeleteAllRows
for i = 1 to 10 // add 10 rows
me.AddRow ""
next
// a cool core class method:
// this will set all columns as appropriate and trigger the ColumnFill event,
// if ColumnFill event returns false (default if left empty)
// then the Fill event of BrowseColumn class will automatically trigger
// else anything is up to you
me.FillColumns
At this point a BrowseColumn object has already been created for every column of the list according to your settings so, if you want to add more columns, remember to create them
ResizeMoveBox class has
method:
• FillColumns this simple call will set all columns as appropriate and
fire the ColumnFill event letting you populate all your list columns.
if ColumnFill event returns false (default if left empty)
then the Fill event of BrowseColumn class will automatically trigger
else anything is up to you
FillColumns method calls the Fill method of each BrowseColumn.
events:
• ColumnFill this event is triggered by the FillColumns method giving you the control
here you could do all necessary steps to make your fill methods work
If false is returned, then the Fill event in BrowseColumn will fire
If true is returned, then the Fill event in BrowseColumn will not fire
BrowseColumn class has
constructor:
• New BrowseColumn(theBox as ResizeMoveBox, theCol as Integer) as BrowseColumn
theCol parameter is stored permanently in the Col private property of the BrowseColumn thus allowing a permanent reference by its original position
Properties:
• Alignment as Integer the alignment style for the column; handles standard RealBasic ColumnAlignment values
• AlignmentOffset as Integer the alignment style; handles standard RealBasic ColumnAlignmentOffset values
• Heading as String the heading text for the column
• Indexed as Boolean true if the Heading of the column has been clicked; only one column should have this set to true
• Type as Integer the column type; handles standard RealBasic ColumnType values
• Width as Integer the column width; handles only absolute pixel values.
SORRY! relative percent values are NOT supported
methods:
• Fill(theCol as Integer) this method will fire the fill event of the class;
It's intended for the creation of subclasses of BrowseColumn and will hold your custom methods to populate it with data
• FillRow(theRow as Integer, theCol as Integer) this method will fire the fillrow event
It's intended for the creation of subclasses of BrowseColumn and will hold your custom methods to populate it with data
• OriginalCol() as Integer this will return the original number of the column stored in the Col Property when first created
events:
• Fill(theCol as Integer) this event is fired by the fill method of the class;
It's intended for the creation of subclasses of BrowseColumn and will hold your custom methods to populate it with data
• FillRow(theRow as Integer, theCol as Integer) this event is fired by the fillRow method and will let you fill the list row and column passed according to values stored in properties
Well, that's all folks!
Of course this is provided as is, disclaim any damage may it produce to your data and bla…bla…bla…
Use it as you like and please feed my EGO mentioning me in your credits.
Comments and suggestions, as well as bug reports, are welcome at musicbox@tin.it